package com.roger.uia.helper.manager;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.provider.Settings;
import android.support.test.InstrumentationRegistry;
import android.telephony.TelephonyManager;
import android.util.Log;

public class Telephony {
    private static final String TAG = "Test" + Telephony.class.getSimpleName();
    private TelephonyManager telManager = (TelephonyManager) InstrumentationRegistry.getTargetContext().getSystemService(Context.TELEPHONY_SERVICE);

    public static Telephony tel(){ return new Telephony();}

    public boolean hasSIM(){
        return telManager.getSimState() == TelephonyManager.SIM_STATE_READY;
    }

    @SuppressLint({"MissingPermission", "HardwareIds"})
    public boolean isLTE(){
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
            String android_id = Settings.System.getString(InstrumentationRegistry.getTargetContext().getContentResolver(), Settings.Secure.ANDROID_ID);
            return !"".equals(android_id);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            if (null == telManager.getImei()) return false;
            return !"".equals(telManager.getImei());
        } else {
            if (null == telManager.getDeviceId()) return false;
            return !"".equals(telManager.getDeviceId());
        }
    }

}
